package cn.iocoder.yudao.module.pay.channel.controller.admin;

import cn.iocoder.yudao.framework.business.basic.controller.ListController;
import cn.iocoder.yudao.framework.business.basic.controller.SimpleDetailController;
import cn.iocoder.yudao.framework.business.basic.controller.UpdateController;
import cn.iocoder.yudao.framework.business.basic.pojo.dto.SimpleQueryDTO;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.pay.channel.service.PayChannelService;
import cn.iocoder.yudao.module.pay.channel.vo.PayChannelSaveDTO;
import cn.iocoder.yudao.module.pay.channel.vo.PayChannelVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 支付渠道")
@RestController
@RequestMapping("/pay/channel")
@Validated
public class PayChannelController implements UpdateController<PayChannelSaveDTO>, SimpleDetailController<PayChannelVO>, ListController<PayChannelVO, SimpleQueryDTO> {

    @Resource
    private PayChannelService payChannelService;

    @PreAuthorize("@ss.hasAnyRoles('super_admin', 'platform_admin', 'tenant_admin')")
    @Override
    public CommonResult<Boolean> update(PayChannelSaveDTO param) {
        return success(payChannelService.update(param));
    }

    @PreAuthorize("@ss.hasAnyRoles('super_admin', 'platform_admin', 'tenant_admin')")
    @Override
    public CommonResult<PayChannelVO> getDetail(Long id) {
        return success(payChannelService.getDetail(id));
    }

    @PreAuthorize("@ss.hasAnyRoles('super_admin', 'platform_admin', 'tenant_admin')")
    @Override
    public CommonResult<List<PayChannelVO>> getList(SimpleQueryDTO param) {
        return success(payChannelService.getList(param));
    }

}
